dofile(os.getenv("LUAR_HOME").."/util/File.lua");

function execute()
	if arg[2] == nil then
		print("Application name not specified. Please enter:");
		arg[2] = io.read();
	end
	local strlen = string.len(arg[2]);
	if string.sub(arg[2], strlen, strlen) == "/" then
		arg[2] = string.sub(arg[2], 1, strlen-1);
	end

	local file = File{};

		--file:createNewDir(arg[2].."/luar-app") == false or 
	if 	file:createNewDir(arg[2]) == false or 
		file:createNewDir(arg[2].."/media") == false or
		file:createNewDir(arg[2].."/media/audio") == false or	
		file:createNewDir(arg[2].."/media/image") == false or
		file:createNewDir(arg[2].."/media/lua") == false or 
		file:createNewDir(arg[2].."/media/text") == false or
		file:createNewDir(arg[2].."/media/video") == false or
		file:createNewDir(arg[2].."/media/ncl") == false or
		file:createNewDir(arg[2].."/media/others") == false or
		file:createNewDir(arg[2].."/target") == false then
		return false;
	end
	local nclCode = [[<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Generated by Luar -->
<ncl id="main_ncl_file" xmlns="http://www.ncl.org.br/NCL3.0/EDTVProfile">
	<head>		
		<regionBase>
	
		</regionBase>
		<descriptorBase>
		
		</descriptorBase>
		<connectorBase>
		
		</connectorBase>				
	</head>
	<body>
	</body>
</ncl>]];
	file:writeFile(arg[2].."/main.luar", nclCode);
	file:writeFile(arg[2].."/.manifest","<type>luar-application</type>\n");
	return true;	
end
